package api;

import java.util.Random;

/**
 * @Author admin
 * @Date 2019/3/27 10:40
 */
public class Mathtest {
    public static void main(String[] args) {
        System.out.println("向下取整:"+Math.floor(5.6));
        System.out.println("四舍五入5.6:"+Math.round(5.6));
        System.out.println("2的3次方:"+Math.pow(2,3));
        System.out.println("2和6的最大值:"+Math.max(2,6));
        System.out.println("0和1之间的随机数:"+Math.random());
        Random r = new Random();
        System.out.println("使用Random类生成int型随机数："+r.nextInt());
        System.out.println("使用Random类生成1到100的随机数"+(r.nextInt(100)+1));
        System.out.println("使用Random()构造方法生成五个随机数（执行2次值不同）:");
        for (int i=0;i<5;i++){
            System.out.println(r.nextInt(100));
        }

        Random r2=new Random(5);
        System.out.println("使用Random（long）构造方法生成5个随机数（执行两次值一样）：");
        for (int i=0;i<5;i++){
            System.out.println(r2.nextInt(100));
        }
    }
}
